/**
 * InvientEngine - Experimental physics and graphics library
 * Copyright (C) 2011  Shane Transue
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/gpl.html
 *
 * No line in this file should exceed 80 characters in width.
 */

package com.invient.core.perf;

/**
 * The Tuple class represents a set of 3 integer values. This class was designed
 * with performance in mind, therefore this class and it's implementation should
 * adhere to that principle.
 */
public class Tuple3i extends Tuplei
{
    protected static final int TOUPLE_SIZE = 3;
    protected static final int ELEMENT_0 = 0;
    protected static final int ELEMENT_1 = 1;
    protected static final int ELEMENT_2 = 2;
    
    /**
     * Creates a new Tuple3i with the default element values provided by the
     * INITIALIZATION_VALUE constant.
     */
    public Tuple3i() {
        this.data = new int[TOUPLE_SIZE];
        this.data[ELEMENT_0] = INITIALIZATION_VALUE;
        this.data[ELEMENT_1] = INITIALIZATION_VALUE;
        this.data[ELEMENT_2] = INITIALIZATION_VALUE;
    }
    
    /**
     * Creates a new Tuple3i from the provided data array.
     *
     * @param data The data array that will be copied into this Tuple.
     * @throws IllegalArgumentException If the input data array is null
     * or if the input data array has a length of 0 or does not match the
     * size of this Tuple: TOUPLE_SIZE.
     */
    public Tuple3i(int[] data) {
        if ( data == null )
            throw new IllegalArgumentException("[Tuple3i] Error creating" + 
                " Tuple3i with null data array");
        if ( data.length == 0 || data.length != TOUPLE_SIZE )
            throw new IllegalArgumentException("[Tuple3i] Error creating" +
                " Tuple3i with data array of size: " + data.length);
                
        this.data = data;
    }
}